/*
 * Created on Fri Dec 17 16:57:41 CET 2010
 */

/* 
 * This Bundle subscribes to service who expose sensors value.
 * It also implements a service who expose alerts 
 */

package org.ece.meteo.eventH;

import java.util.*;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.event.EventConstants; 
import org.osgi.service.event.EventHandler;

public class Activator implements BundleActivator {
	static BundleContext BC;
	
	/**
	 * Implements Activator.start(). Prints that it is starting and
	 * exports a new service through EventHandlerImpl().
	 * @param context the framework context for the bundle.
	**/	
    public void start(BundleContext context) throws Exception {  
    	BC = context;
    	
        String[] topics = new String[] {
                "org/ece/meteo/capteur*"
            };
            
            Dictionary props = new Hashtable();
            props.put(EventConstants.EVENT_TOPIC, topics);
            // register the service to the FW
            context.registerService(EventHandler.class.getName(), new EventHandlerImpl() , props);
    		System.out.println("> org.ece.meteo.eventH started");
    	
    }  
      
	/**
	 * Implements Activator.stop(). Prints that it is stopping
	 * @param context the framework context for the bundle.
	**/     
    public void stop(BundleContext bundleContext) throws Exception {  
  	  // all is done by the Framework
		System.out.println("> org.ece.meteo.eventH resolved");
    }  
      
}